import { Transform } from 'class-transformer';
import { DtoValidation } from '../decorators/dto-validation.decorator';
import { IsNumber, IsOptional, Min } from 'class-validator';
import { Trash } from './trashed.dto';

@DtoValidation({ type: 'query' })
export class CommonPaginationServiceDto extends Trash {
  @Transform((value) => {
    return Number(value.value);
  })
  @IsOptional({
    always: true,
  })
  @Min(1, { message: '值必须大于1' })
  @IsNumber()
  pageNumber = 1;

  @Transform((value) => {
    return Number(value.value);
  })
  @IsOptional({
    always: true,
  })
  @Min(1, { message: '值必须大于1' })
  @IsNumber()
  pageSize = 5;
}
